import React from 'react';
import {
  View,
  Text,
  ScrollView,
  TouchableOpacity,
  Alert,
} from 'react-native';

import SizeUtils from '../../common/SizeUtils';
import Config from '../../config';
import TImage from '../../components/TImage';
import BasePage from '../common/BasePage';
import ToastUtils from '../../common/ToastUtils';
import UserRequestAPPConfigAction from '../../actions/user/UserRequestAPPConfigAction';
//
export default class HeartVolunteerAgreementPage extends BasePage {
  constructor(props) {
    super(props);
    this.config_key="volunteer_agreement_config";
    this._initUrl();

  }

   _dealEnterPage() {
    this._initUrl();
  }

  _initUrl() {
    var date = new Date();
    if(!this.lastGetDate || this.lastGetDate.getTime() - date.getTime() > 300000){
      this.lastGetDate = date;
      new UserRequestAPPConfigAction().call(this, {key:this.config_key,requestType:"config"});
    }
  }

  render() {
    return (
      <View style={{width:SizeUtils.getWindowSize().width,paddingTop:Config.paddingTop,
          height:SizeUtils.getWindowSize().height, backgroundColor:"#ffffff"}}>
        <ScrollView style={{flex:1,
           height:SizeUtils.getWindowSize().height - Config.paddingTop - SizeUtils.translateDesignHeightToCode(120),}}>
          <View style={{width:SizeUtils.getWindowSize().width - SizeUtils.translateDesignWidthToCode(80),
              marginLeft:SizeUtils.translateDesignWidthToCode(40),
              flexDirection:"column"}}>
            <Text style={{color:"#333333", fontSize:SizeUtils.translateFontSizeToCode(28),
            lineHeight:SizeUtils.translateDesignWidthToCode(56),
                marginTop:SizeUtils.translateDesignHeightToCode(38),}}>
            {this.state.configData ? "      "+this.state.configData.value:""}
          </Text>
          </View>
        </ScrollView>
        {this._renderBottom()}
        {this._renderNavigationBar()}
      </View>
    )
  }

  _renderBottom(){
    return (<TouchableOpacity
            style={{
              width:SizeUtils.getWindowSize().width,
              backgroundColor: '#D93338',
              height:SizeUtils.translateDesignHeightToCode(100),
              flexDirection:"row", alignItems:"center", justifyContent:"center",
            }}
            onPress={this._onPressSubmit.bind(this)}
           >
             <Text style={{
                textAlign: 'center',
                color: '#ffffff',
                fontSize:SizeUtils.translateFontSizeToCode(32),
              }}>我已知晓，确认加入</Text>
           </TouchableOpacity>);
  }

  _onPressSubmit(){
     this.gotoPage(Config.pages.heart_volunteer_submit);
  }

}
